package com.example.demo.service.serviceImpl;

import com.example.demo.common.MessageBody;
import com.example.demo.controller.bfzx.YpbfController;
import com.example.demo.mapper.YpbfMapper;
import com.example.demo.service.YpbfService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created hongsou
 * author:fh
 * Date:2019/4/28
 * Time:14:07
 * desc:
 **/
@Service
public class YpbfServiceImpl implements YpbfService {
    private static final Logger logger = LoggerFactory.getLogger(YpbfServiceImpl.class);

    @Autowired
    private YpbfMapper ypbfMapper;

    @Override
    public MessageBody getYpbfrwList(String dalbDm, String bfplDm, String bfQsrq, String bfZzrq) {
        List<Map<String, String>> ypbfrwList = ypbfMapper.getYpbfrwList(dalbDm, bfplDm, bfQsrq, bfZzrq);
        logger.info(ypbfrwList.toString());

        if (!ypbfrwList.toString().contains("rwId")) {
            return MessageBody.getCostomMessageBody("暂无硬盘备份任务", true);
        }
        return MessageBody.getMessageBody(ypbfrwList);
    }

    @Override
    public MessageBody getGpbfrwList(String dalbDm, String bfplDm, String bfQsrq, String bfZzrq) {
        List<Map<String, String>> getGpbfrwList = ypbfMapper.getGpbfrwList(dalbDm, bfplDm, bfQsrq, bfZzrq);
        logger.info(getGpbfrwList.toString());
        if (!getGpbfrwList.toString().contains("rwId")) {
            return MessageBody.getCostomMessageBody("暂无光盘备份任务", true);
        }
        return MessageBody.getMessageBody(getGpbfrwList);
    }

    /**
     *  @auther: fh
     *  @date    2019/4/29 16:38
     *  @des    光盘复制任务
     */
    @Override
    public MessageBody getGpfzrwList(String dalbDm, String bfQsrq, String bfZzrq) {
        List<Map<String, String>> gpfzrwList = ypbfMapper.getGpfzrwList(dalbDm, bfQsrq, bfZzrq);
        logger.info(gpfzrwList.toString());
        if (!gpfzrwList.toString().contains("rwId")) {
            return MessageBody.getCostomMessageBody("暂无光盘备份任务", true);
        }
        return MessageBody.getMessageBody(gpfzrwList);
    }
}
